package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.dto.NursingProjectDto;
import com.zzyl.service.NursingPlanService;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "护理计划管理")
@RestController
@RequestMapping("/nursing")
public class NursingPlanController extends BaseController{

    @Autowired
    private NursingPlanService nursingPlanService;

    @GetMapping("/plan")
    @ApiOperation("查询全部护理计划")
    public ResponseResult<List<NursingPlanVo>> getAll(){
        List<NursingPlanVo> nursingPlanVos=nursingPlanService.getAll();
        return ResponseResult.success(nursingPlanVos);
    }

    @PostMapping("/plan")
    @ApiOperation("添加护理计划")
    public ResponseResult addNursingPlan(@RequestBody NursingPlanDto nursingPlanDto){

        nursingPlanService.addNursingPlan(nursingPlanDto);

        return ResponseResult.success();
    }

    @GetMapping("/plan/search")
    @ApiOperation(value ="获取护理计划列表", notes = "返回护理计划列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "integer", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "integer", paramType = "query"),
            @ApiImplicitParam(name = "planName", value = "护理项目名称", dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态（0：禁用，1：启用）", dataType = "integer", paramType = "query")
    })
    public ResponseResult<PageResponse> selectByPage(Integer pageNum, Integer pageSize, String name, Integer status){

        return success(nursingPlanService.selectByPage(pageNum, pageSize, name, status));
    }

    @GetMapping("/plan/{id}")
    @ApiOperation(value = "根据id查询护理计划")
    public ResponseResult<NursingPlanVo> selectById(@PathVariable Long id) {
        NursingPlanVo nursingPlanVo = nursingPlanService.selectById(id);
        return success(nursingPlanVo);
    }

    @PutMapping("/plan")
    @ApiOperation("修改护理计划")
    public ResponseResult updateNursingPlan(@RequestBody NursingPlanDto nursingPlanDto) {
        nursingPlanService.update(nursingPlanDto);
        return success();
    }

    @DeleteMapping("/plan/{id}")
    @ApiOperation("删除护理计划")
    public ResponseResult deleteById(@PathVariable Long id) {

        nursingPlanService.deleteById(id);
        return success();
    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("更新计划状态")
    public ResponseResult updateStatus( @PathVariable Long id, @PathVariable Integer status) {
        nursingPlanService.updateStatus(id, status);
        return ResponseResult.success();
    }
}
